package com.gaoxin.api.service.feeservice;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gaoxin.api.dao.feedao.QueryStuFeeDao;
import com.gaoxin.api.entity.ConfigEntity;
import com.gaoxin.api.entity.eduentity.Clazz;
import com.gaoxin.api.entity.feeentity.StuFeeEntity;
import com.gaoxin.api.entity.stuentity.StuInfoEntity;

/**
 * 查询学生缴费接口-业务层
 *
 * @author fanyue
 * @email 859485490@qq.com
 * @date 2018-07-12 15:21
 */
@Service
public class QueryStuFeeService {
	Logger log = Logger.getLogger("~~QueryStuFeeService~~~~~~~~");
	@Autowired
	private QueryStuFeeDao queryStuFeeDao;
	@Autowired
	private ConfigEntity configEntity;
	
	
	/**
	 * 查询学生缴费
	 * 
	 * @param stuNumber
	 * @return StuInfoEntity
	 * @throws Exception
	 */
//	public List<StuFeeEntity> queryStuFees(String stuCode, String chargeYear) throws Exception {
	public List<StuFeeEntity> queryStuFees(StuFeeEntity stuFeeEntity) throws Exception {
//		log.info("查询学生缴费开始。。。" + stuCode);
		List<StuFeeEntity> list = new ArrayList<>();
		try {
			list = queryStuFeeDao.queryStuFees(stuFeeEntity);
			for (StuFeeEntity entity : list) {
				String status = "";
				if(entity.getStatus().equals("0")) status = "删除";
				if(entity.getStatus().equals("1")) status = "正常";
				if(entity.getStatus().equals("2")) status = "费用调整变更";
				entity.setStatus(status);
			}
//			System.out.println("***********" + list.toString());
		} catch (Exception e) {
			log.warning("查询学生缴费异常。。。");
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询班级学生基本信息
	 * @param stuNumber
	 * @param classId
	 * @return
	 * @throws Exception
	 */
	public List<StuInfoEntity> queryStuBasicInfo(StuInfoEntity stuInfoEntity) throws Exception {
		List<StuInfoEntity> qSBInfo = queryStuFeeDao.queryStuBasicInfo(stuInfoEntity);
		try {
			for(int i = 0;i<qSBInfo.size();i++){
				String headImage = qSBInfo.get(i).getHeadImage();
				if (!headImage.substring(0, 4).equals("http")) {
					headImage = configEntity.getBaseDirPath() + qSBInfo.get(i).getHeadImage();
					qSBInfo.get(i).setHeadImage(headImage);
				}
			}
		} catch (Exception e) {
			log.warning("查询学生信息异常。。。");
			e.printStackTrace();
		}
		return qSBInfo;
	}
	/**
	 * 查询二级学院
	 * @return
	 * @throws Exception
	 */
	public List<Clazz> queryDept()throws Exception{
		return queryStuFeeDao.queryDept();
	}
	/**
	 * 查询二级学院对应的专业
	 * @param clazz
	 * @return
	 * @throws Exception
	 */
	public List<Clazz> queryMajor(Clazz clazz)throws Exception{
		return queryStuFeeDao.queryMajor(clazz);
	}
	/**
	 * 查询专业下的班级
	 * @param clazz
	 * @return
	 * @throws Exception
	 */
	public List<Clazz> queryClazz(Clazz clazz)throws Exception{
		return queryStuFeeDao.queryClazz(clazz);
	}

}
